package com.example.l2p_feedback;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ExpandableListView;
import android.widget.Toast;

public class View08_ViewAll extends Activity {
	ExpandableListAdapter listAdapter;
	ExpandableListView expListView;
	List<String> listDataHeader;
	HashMap<String, List<String>> listDataChild;

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.view08_menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.suggestion:
			Toast.makeText(this, "New suggestion in progress",
					Toast.LENGTH_SHORT).show();
			break;
		case R.id.question:
			Toast.makeText(this, "New question in progress",
					Toast.LENGTH_SHORT).show();
			break;
		default:
			break;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_view_topics_main);

		// preparing list data
		prepareListData();

		listAdapter = new ExpandableListAdapter(this, listDataHeader,
				listDataChild);

		// setting list adapter
		expListView = (ExpandableListView) findViewById(R.id.lvExp);
		expListView.setAdapter(listAdapter);

		this.setTitle("DEMO COURSE ROOM");
	}

	/*
	 * Preparing the list data
	 */
	private void prepareListData() {
		listDataHeader = new ArrayList<String>();
		listDataChild = new HashMap<String, List<String>>();

		// Adding child data
		listDataHeader.add("Overall Feedback");
		listDataHeader.add("Course Questions");
		listDataHeader.add("Course Suggestions");

		// Adding child data
		List<String> overallFeedback = new ArrayList<String>();
		overallFeedback.add("3#It was good course where I learnt a lot.");
		overallFeedback.add("3#I am not happy with the course.");

		List<String> courseQuestion = new ArrayList<String>();
		courseQuestion.add("4#Is there any book on data mining algorithms?");
		courseQuestion.add("4#I am unable to download the 'further reading' documents.");

		List<String> courseSuggestion = new ArrayList<String>();
		courseSuggestion.add("5#Sometime too much fast, please be slow to demonstrate algorithms");
		courseSuggestion.add("5#Open the windows");
		courseSuggestion.add("5#Lecture content should be given beforehand");

		listDataChild.put(listDataHeader.get(0), overallFeedback);
		listDataChild.put(listDataHeader.get(1), courseQuestion);
		listDataChild.put(listDataHeader.get(2), courseSuggestion);
	}
}
